package com.hhsjtest.alipaydragview.impl;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.hhsjtest.appdraglayout.alipay.AlipayDragFrameLayout;


public class CustomFrameLayout extends AlipayDragFrameLayout<ItemInfo, DefaultDragItemView> {

    public CustomFrameLayout(@NonNull Context context) {
        super(context);
    }

    public CustomFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected View createMiddleView() {
        LinearLayout middleTipsLayout = new LinearLayout(getContext());
        middleTipsLayout.setBackgroundColor(Color.YELLOW);
        MarginLayoutParams middleLayoutParams = new MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100);
        middleLayoutParams.topMargin = 10;
        middleLayoutParams.bottomMargin = 10;
        middleTipsLayout.setLayoutParams(middleLayoutParams);
        return middleTipsLayout;
    }

    @NonNull
    public ViewGroup dragShadowLayoutParent;

    /**
     * This method should be used before getDragShadowParent().
     * @param viewGroup
     */
    public void setDragShadowLayoutParent(@NonNull ViewGroup viewGroup) {
        this.dragShadowLayoutParent = viewGroup;
    }

    @NonNull
    @Override
    public View getDragShadowParent() {
        return dragShadowLayoutParent;
    }
}
